<?php
	
	//Include class
	require_once('mysqldump.php');
    require_once 'zip.lib.php';
    require_once 'conexao.php';
    
    $connessione = new conexao();
    $connessione->abrir();
    
    $endereco = 'C:\backup_'.date('Y-m-d').'_'.date('H-i-s').'.sql';
    $arquivo = $endereco;
	//Create new instance of MySQLDump
  $dumper = new MySQLDump($connessione->getDb());
  
	//If you want to write the MySQL dump to file
  $dumper->writeDump($arquivo);

  //If you want to get on string the MySQL dump
  $str = $dumper->getDump();
  
  //If you want to change the database
  //$dumper->setDatabase('database_2');
  
  //If you want to get only the database structure
  $str = $dumper->getStructure();

  //If you want to get only the database data
  $str = $dumper->getData();

	
 //Zipando o arquivo criado acima  
  $zipfile = new zipfile('backup_'.date('Y-m-d').'_'.date('H-i-s').'.sql.zip');


  $zipfile->addFileAndRead($arquivo);

  //Disponibilizando o danado para donwload
  echo $zipfile->file();
  
  //Removendo o arquivo temporario criado
  unlink($endereco);
		
?>